package com.sunny.blog.common.entity;

/**
 * @ClassName: Response
 * @Description: 将结果转换为封装后的对象
 * @Author: sunt
 * @Date: 2019/6/515:13
 **/
public class Response {

    private final static String SUCCESS = "true";

    private final static String FAIL = "false";

    private final static String SUCC_MSG = "执行成功";

    private final static String FAIL_MSG = "系统异常,请稍后重试";

    public static <T> ResponseResult<T> makeOKRsp() {
        return new ResponseResult<T>().setCode(ResultCode.SUCCESS).setMsg(SUCCESS);
    }

    public static <T> ResponseResult<T> makeErrRsp() {
        return new ResponseResult<T>().setCode(ResultCode.FAIL).setMsg(FAIL_MSG);
    }

   /* public static <T> ResponseResult<T> makeOKRsp(String message) {
        return new ResponseResult<T>().setCode(ResultCode.SUCCESS).setMsg(message);
    }*/

    public static <T> ResponseResult<T> makeOKRsp(T data) {
        return new ResponseResult<T>().setCode(ResultCode.SUCCESS).setMsg(SUCC_MSG).setData(data);
    }

    public static <T> ResponseResult<T> makeErrRsp(String message) {
        return new ResponseResult<T>().setCode(ResultCode.FAIL).setMsg(message);
    }

    public static <T> ResponseResult<T> makeRsp(int code, String msg) {
        return new ResponseResult<T>().setCode(code).setMsg(msg);
    }

    public static <T> ResponseResult<T> makeRsp(int code, String msg, T data) {
        return new ResponseResult<T>().setCode(code).setMsg(msg).setData(data);
    }

}
